{template 'common/header'}
{template 'common'}
<ul class="nav nav-tabs">
    <li {if $operation=='display'} class="active" {/if}>
    <a href="{php echo $this->createWebUrl('insuranceprice',array('op' =>'display'))}">保险价格列表</a>
    </li>
    <li {if empty($insurance_price['id']) && $operation == 'post'} class="active" {/if}>
    <a href="{php echo $this->createWebUrl('insuranceprice',array('op' =>'post'))}">添加保险价格</a>
    </li>
    {if !empty($insurance_price['id']) && $operation == 'post'}
    <li class="active">
        <a href="{php echo $this->createWebUrl('insurance_price',array('op' =>'post','id'=>$insuranceprice['id']))}">编辑保险价格</a>
    </li>
    {/if}
</ul>

<!--列表-->
{if $operation == 'display'}
<div class="main panel panel-default">
    <div class="panel-body table-responsive">
        <table class="table table-hover">
            <thead class="navbar-inner">
            <tr>
                <th style="width:30px;">ID</th>
                <th>保险名称</th>
                <th>时长</th>
                <th>成人单价</th>
                <th>未成人单价</th>
                <th>操作</th>
            </tr>
            </thead>
            <tbody>
            {loop $list $insurance_price}
            <tr>
                <td>{$insurance_price['id']}</td>
                <td>{$insurance_price['name']}</td>
                <td>{$insurance_price['start_days']} ～ {$insurance_price['end_days']} 天</td>
                <td>{$insurance_price['adult_price']}</td>
                <td>{$insurance_price['child_price']}</td>
                <td style="text-align:left;">
                    <a href="{php echo $this->createWebUrl('insuranceprice', array('op' => 'post', 'id' => $insurance_price['id']))}"
                       class="btn btn-default btn-sm" data-toggle="tooltip" data-placement="top" title="修改">
                        <i class="fa fa-edit"></i>
                    </a>
                    <a href="{php echo $this->createWebUrl('insuranceprice', array('op' => 'delete', 'id' => $insurance_price['id']))}"
                       class="btn btn-default btn-sm" data-toggle="tooltip" data-placement="top" title="删除">
                        <i class="fa fa-times"></i>
                    </a>
                </td>
            </tr>
            {/loop}
            </tbody>
        </table>
        {$pager}
    </div>
</div>
<script>
    require(['bootstrap'], function ($) {
        $('.btn').hover(function () {
            $(this).tooltip('show');
        }, function () {
            $(this).tooltip('hide');
        });
    });
</script>

<!--增加修改-->
{elseif $operation == 'post'}
<div class="main">
    <form id="form1" action="" method="post" class="form-horizontal form" enctype="multipart/form-data">
        <input type="hidden" name="id" value="{$insurance_price['id']}"/>
        <div class="panel panel-default">
            <div class="panel-heading">
                保险价格设置
            </div>
            <div class="panel-body">
                <div class="form-group">
                    <label class="col-xs-12 col-sm-3 col-md-2 control-label" for="insurance_id">
                        <span style="color:red">*</span>
                        保险类型
                    </label>
                    <div class="col-sm-9 col-xs-12">
                        <select name="insurance_id" id="insurance_id" class="form-control">
                            <option value="">==请选择保险类型==</option>
                            {loop $insurances $insurance}
                            <option value="{$insurance['id']}" {if $insurance_price['insurance_id'] == $insurance['id']}selected{/if}>{$insurance['name']}</option>
                            {/loop}
                        </select>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-xs-12 col-sm-3 col-md-2 control-label" for="start_days">
                        <span style="color:red">*</span>
                        开始时长
                    </label>
                    <div class="col-sm-9 col-xs-12">
                        <input type="number" id='start_days' name="start_days" class="form-control"
                               value="{$insurance_price['start_days']}"/>
                        <span class="help-block">如：1,即1-7天里的1</span>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-xs-12 col-sm-3 col-md-2 control-label" for="end_days">
                        <span style="color:red">*</span>
                        结束时长
                    </label>
                    <div class="col-sm-9 col-xs-12">
                        <input type="number" id='end_days' name="end_days" class="form-control"
                               value="{$insurance_price['end_days']}"/>
                        <span class="help-block">如：7,即1-7天里的7</span>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-xs-12 col-sm-3 col-md-2 control-label" for="adult_price">
                        <span style="color:red">*</span>
                        成人单价
                    </label>
                    <div class="col-sm-9 col-xs-12">
                        <input type="number" id='adult_price' name="adult_price" class="form-control"
                               value="{$insurance_price['adult_price']}"/>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-xs-12 col-sm-3 col-md-2 control-label" for="child_price">
                        <span style="color:red">*</span>
                        未成人单价
                    </label>
                    <div class="col-sm-9 col-xs-12">
                        <input type="number" id='child_price' name="child_price" class="form-control"
                               value="{$insurance_price['child_price']}"/>
                    </div>
                </div>
            </div>
        </div>

        <div class="form-group col-sm-12">
            <input type="submit" name="submit" value="提交" class="btn btn-primary col-lg-1"/>
            <input type="hidden" name="token" value="{$_W['token']}"/>
        </div>
    </form>
</div>

<script language='javascript'>
    $(function () {
        var trip_add = 0;
        $("#form1").submit(function () {
            if ($(":text[name='insurance_id']").val() == '') {
                Tip.focus("insurance_id", "请填写保险价格保险类型!");
                return false;
            }
            if ($(":text[name='tag']").val() == '') {
                Tip.focus("tag", "请填写标签!");
                return false;
            }
            if ($(":text[name='name']").val() == '') {
                Tip.focus("name", "请填写保险价格名称!");
                return false;
            }
            if ($(":text[name='price']").val() == '') {
                Tip.focus("price", "请填写保险价格价格!");
                return false;
            }
            if ($(":text[name='currency']").val() == '') {
                Tip.focus("currency", "请填写保险价格货币种类!");
                return false;
            }
            if ($(":text[name='thumb']").val() == '') {
                Tip.focus("thumb", "请填上传缩略图!");
                return false;
            }
            if ($(":text[name='intro']").val() == '') {
                Tip.focus("intro", "请填写简要说明!");
                return false;
            }
            return true;
        });
    });
</script>
{/if}
{template 'common/footer'}